#include "../StdInc.h"
#include <boost/format.hpp>

namespace GSTrader
{
	namespace TradeStrategy
	{
		CStrategyParameterInfo::CStrategyParameterInfo()
		{
			m_strParameterName = "";
			m_nType = -1;
			m_pParameter = NULL;
			m_strDescription = "";
		}


		CStrategyParameterInfo::~CStrategyParameterInfo()
		{
		}

		string CStrategyParameterInfo::ToString()
		{
			if (m_nType < 0 || m_pParameter == NULL)
				return "";

			boost::format fmt(g_language == slChinese ? Chinese::c_szFmt128 : English::c_szFmt128);
			fmt % m_strParameterName.c_str();
			fmt % (g_language == slChinese ? Chinese::c_ParamType[m_nType] : English::c_ParamType[m_nType]);

			switch (m_nType)
			{
			case paramInt:
			{
				char sz[30];
				int nValue = *((int*)(m_pParameter));
				sprintf(sz, "%d", nValue);
				fmt % sz;
			}
			break;
			case paramBool:
			{
				bool bValue = *((bool*)(m_pParameter));
				fmt % (bValue ? "true" : "false");
			}
			break;
			case paramDouble:
			{
				char sz[100];
				double dValue = *((double*)(m_pParameter));
				sprintf(sz, "%f", dValue);
				fmt % sz;
			}
			break;
			case paramString:
			{
				string * p = (string*)m_pParameter;
				string strValue = *((string*)(m_pParameter));
				fmt % strValue.c_str();
			}
			break;
			default:
				fmt % "";
			}

			return fmt.str();
		}
	}
}
